;; set default utf-8
(prefer-coding-system 'utf-8)

;; enable y/n answers
(fset 'yer-or-no-p 'y-or-n-p)
(global-visual-line-mode 0)

;; ring bell
(setq ring-bell-function 'ignore)

;; disable backup
(setq make-backup-files nil)
(setq backup-inhibited t)

;; disable auto save
(setq auto-save-list-file-prefix nil)
(setq auto-save-default nil)

;; Set clipboard kill ring
(setq kill-ring-max 200)

;; Set message buffer
(setq message-log-max 10000)

;; which-key
(use-package which-key
  :config (which-key-mode))

;; Global company
(global-company-mode t)

;; use custom.el
(setq custom-file (expand-file-name "damacs-custom.el" damacs-core-dir))
(when (file-exists-p custom-file) (load custom-file))

;; Emacs proxy
;; (setq url-gateway-method 'socks)
;; (setq socks-server '("Default server" "127.0.0.1" 1080 5))

;; Set ido mode
;; From Lazycat
;; lazycat-toolkit.el
(ido-mode t)
(setq ido-enable-flex-matching t)
(setq ido-everywhere nil)
(defun ido-sort-mtime ()
  "Sort ido item by modified time."
  (let (ido-temp-list)
    (setq ido-temp-list
          (sort ido-temp-list
                (lambda (a b)
                  (let ((ta (nth 5 (file-attributes (concat ido-current-directory a))))
                        (tb (nth 5 (file-attributes (concat ido-current-directory b)))))
                    (if (= (nth 0 ta) (nth 0 tb))
                        (> (nth 1 ta) (nth 1 tb))
                      (> (nth 0 ta) (nth 0 tb)))))))
    (ido-to-end ;; move . files to end (again)
     (delq nil (mapcar
                (lambda (x) (if (string-equal (substring x 0 1) ".") x))
                ido-temp-list)))))
(add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
(add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)

;; Set up ibuffer
(defalias 'list-buffers 'ibuffer)

;; Set Magit
(use-package magit)

;; Set Auto Insert
(setq auto-insert-mode-query nil)

;; Set better defaults
(setq better-defaults-move-to-end-of-code-first t)



(provide 'damacs-config)
